/* ftok
 * 
 * convert a pathname and a project identifier to a System V IPC key
 */

#include <sys/types.h>
#include <sys/ipc.h>

key_t ftok(const char *pathname, int proj_id);


/* msgget
 *  - get a System V message queue identifier
 *
 * msgctl
 *  - System V message control operations
 *
 * msgrcv, msgsnd
 *  - System V message queue operations
 */

#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/msg.h>

int msgget(key_t key, int msgflg);

int msgctl(int msqid, int cmd, struct msqid_ds *buf);

int msgsnd(int msqid, const void *msgp, size_t msgsz, int msgflg);

ssize_t msgrcv(int msgid, void *msgp, size_t msgsz, long msgtyp, int msgflg);

struct msqid_ds {
    struct ipc_perm msg_perm;       /* Ownership and permissions */
    time_t          msg_stime;      /* Time of last msgsnd */
    time_t          msg_rtime;      /* Time of last msgrcv */
    time_t          msg_ctime;      /* Time of last change */
    unsigned long   __msg_cbytes;   /* Current number of bytes in
                                       queue (nonstandard) */
    msgqnum_t       msg_qnum;       /* Current number of messages in queue */
    msglen_t        msg_qbytes;     /* Maximum number of bytes
                                       allowed in queue */
    pid_t           msg_lspid;      /* PID of last msgsnd */
    pid_t           msg_lrpid;      /* PID of last msgrcv */
}

struct ipc_perm {
     key_t          __key;      /* Key supplied to msgget */
     uid_t          uid;        /* Effective UID of owner */
     gid_t          gid;        /* Effective GID of owner */
     uid_t          cuid;       /* Effective UID of creater */
     gid_t          cgid;       /* Effective GID of creater */
     unsigned short mode;       /* Permissions */
     unsigned short __seq;      /* Sequence number */
}

struct msgbuf {
    long mtype;         /* message type, must be > 0 */
    char mtext[1];      /* message data */
}
